package graph_viewer.canvas;

import graph_viewer.structure.Node;
/**
	stort the options of drawing graph on canvas
*/
public class Canvas_Metrics{
	boolean
		has_label, has_DOI, is_closed, is_distortion_at_center;
	int threshold_order;
	Node focus;

	public Canvas_Metrics( boolean has_label, boolean has_DOI, boolean is_closed, boolean is_distortion_at_center, int threshold_order, Node focus ){
		set_has_label( has_label );
		set_has_DOI( has_DOI );
		set_is_closed( is_closed );
		set_is_distortion_at_center( is_distortion_at_center );
		set_threshold_order( threshold_order );
		set_focus( focus );
	}

	public Canvas_Metrics(){
		this( true, false, false, false, Integer.MIN_VALUE, null );
	}

	//=======================================
	// setter & getter
	//=======================================
	public void set_has_label( boolean has_label ){
		this.has_label = has_label;
	}

	public boolean get_has_label(){
		return this.has_label;
	}

	public void set_has_DOI( boolean has_DOI ){
		this.has_DOI = has_DOI;
	}

	public boolean get_has_DOI(){
		return this.has_DOI;
	}
	
	public void set_is_closed( boolean is_closed ){
		this.is_closed= is_closed;
	}
	
	public boolean get_is_closed(){
		return this.is_closed;
	}

	public void set_is_distortion_at_center( boolean is_distortion_at_center ){
		this.is_distortion_at_center	= is_distortion_at_center;
	}
	
	public boolean get_is_distortion_at_center(){
		return is_distortion_at_center;
	}

	public Node get_focus(){
		return this.focus;
	}

	public void set_focus( Node focus ){
		this.focus	= focus;
	}

	public void set_threshold_order( int threshold_order ){
		this.threshold_order = threshold_order;
	}

	public int get_threshold_order(){
		return this.threshold_order;
	}

	//=======================================
	// public methods
	//=======================================
	public int find_thresholding(){
		return this.make_threshold_value_by_order();
	}

	//=======================================
	// util
	//=======================================
	// convert DOI expression from order to value
	// this method is particular for a tree structure: order * 2 + foucs'DOI
	private int make_threshold_value_by_order(){
		if ( this.focus == null ){
			return 0;
		}else{
			return this.focus.get_DOI() - threshold_order * 2;
		}
	}
}
